﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>LangChain智能客服系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .container {
            width: 95%;
            max-width: 1200px;
            height: 90vh;
            background: white;
            border-radius: 20px;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
            display: flex;
            overflow: hidden;
        }

        /* 左侧边栏 */
        .sidebar {
            width: 250px;
            background: #4a6bdf;
            color: white;
            padding: 25px 15px;
            display: flex;
            flex-direction: column;
        }

        .logo {
            text-align: center;
            margin-bottom: 30px;
            font-size: 24px;
            font-weight: bold;
            display: flex;
            align-items: center;
            justify-content: center;
        }

            .logo i {
                margin-right: 10px;
            }

        .nav-item {
            padding: 15px;
            margin: 8px 0;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s;
            display: flex;
            align-items: center;
        }

            .nav-item i {
                margin-right: 10px;
                font-size: 18px;
            }

            .nav-item:hover, .nav-item.active {
                background: rgba(255, 255, 255, 0.2);
            }

        /* 主聊天区域 */
        .chat-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            border-left: 1px solid #eee;
            border-right: 1px solid #eee;
        }

        .chat-header {
            padding: 20px;
            border-bottom: 1px solid #eee;
            text-align: center;
            background: #f9fafc;
        }

        .chat-messages {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
        }

        .message {
            max-width: 70%;
            padding: 12px 16px;
            margin-bottom: 15px;
            border-radius: 18px;
            line-height: 1.5;
            position: relative;
        }

        .user-message {
            align-self: flex-end;
            background: #4a6bdf;
            color: white;
            border-bottom-right-radius: 5px;
        }

        .bot-message {
            align-self: flex-start;
            background: #f0f4ff;
            color: #333;
            border-bottom-left-radius: 5px;
        }

        .chat-input {
            padding: 20px;
            display: flex;
            border-top: 1px solid #eee;
            background: #f9fafc;
        }

            .chat-input input {
                flex: 1;
                padding: 15px;
                border: 1px solid #ddd;
                border-radius: 30px;
                outline: none;
                font-size: 16px;
                margin-right: 10px;
            }

            .chat-input button {
                width: 50px;
                height: 50px;
                border-radius: 50%;
                border: none;
                background: #4a6bdf;
                color: white;
                cursor: pointer;
                font-size: 18px;
                transition: all 0.3s;
            }

                .chat-input button:hover {
                    background: #3a5bce;
                    transform: scale(1.05);
                }

        /* 右侧面板 */
        .right-panel {
            width: 300px;
            padding: 25px 20px;
            background: #f9fafc;
            overflow-y: auto;
        }

        .panel-section {
            margin-bottom: 30px;
        }

            .panel-section h3 {
                margin-bottom: 15px;
                color: #4a6bdf;
                padding-bottom: 10px;
                border-bottom: 1px solid #eee;
            }

        .knowledge-item {
            padding: 12px;
            background: white;
            border-radius: 10px;
            margin-bottom: 10px;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
            cursor: pointer;
            transition: all 0.3s;
        }

            .knowledge-item:hover {
                transform: translateY(-2px);
                box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            }

        .setting-option {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }

        .switch {
            position: relative;
            display: inline-block;
            width: 50px;
            height: 24px;
        }

            .switch input {
                opacity: 0;
                width: 0;
                height: 0;
            }

        .slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            transition: .4s;
            border-radius: 24px;
        }

            .slider:before {
                position: absolute;
                content: "";
                height: 16px;
                width: 16px;
                left: 4px;
                bottom: 4px;
                background-color: white;
                transition: .4s;
                border-radius: 50%;
            }

        input:checked + .slider {
            background-color: #4a6bdf;
        }

            input:checked + .slider:before {
                transform: translateX(26px);
            }

     

        .sidebar {
            width: 100%;
            flex-direction: row;
            overflow-x: auto;
            padding: 15px 10px;
        }

        .logo {
            margin-bottom: 0;
            margin-right: 20px;
        }

        .nav-items {
            display: flex;
        }

        .nav-item {
            margin: 0 5px;
            white-space: nowrap;
        }

        .right-panel {
            width: 100%;
            order: 3;
        }

        .chat-container {
            order: 2;
        }

        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 左侧边栏 -->
        <div class="sidebar">
            <div class="logo">
                <i class="fas fa-robot"></i>
                <span>LangChain客服</span>
            </div>
            <div class="nav-items">
                <div class="nav-item active">
                    <i class="fas fa-comments"></i>
                    <span>智能对话</span>
                </div>
                <div class="nav-item">
                    <i class="fas fa-database"></i>
                    <span>知识库</span>
                </div>
                <div class="nav-item">
                    <i class="fas fa-cog"></i>
                    <span>设置</span>
                </div>
                <div class="nav-item">
                    <i class="fas fa-history"></i>
                    <span>历史记录</span>
                </div>
                <div class="nav-item">
                    <i class="fas fa-question-circle"></i>
                    <span>帮助中心</span>
                </div>
            </div>
        </div>

        <!-- 主聊天区域 -->
        <div class="chat-container">
            <div class="chat-header">
                <h2>智能客服助手</h2>
                <p>基于LangChain技术驱动，24小时为您服务</p>
            </div>
            <div class="chat-messages" id="chatMessages"></div>
            <div class="chat-input">
                <input type="text" id="userInput" placeholder="输入您的问题...">
                <button id="sendButton"><i class="fas fa-paper-plane"></i></button>
            </div>
        </div>

        <!-- 右侧面板 -->
        <div class="right-panel">
            <div class="panel-section">
                <h3>知识库</h3>
                <div class="knowledge-item">
                    <strong>产品文档</strong>
                    <p>最新产品功能和使用指南</p>
                </div>
                <div class="knowledge-item">
                    <strong>常见问题</strong>
                    <p>用户最常遇到的问题解答</p>
                </div>
                <div class="knowledge-item">
                    <strong>API文档</strong>
                    <p>开发者接口使用说明</p>
                </div>
                <div class="knowledge-item">
                    <strong>更新日志</strong>
                    <p>产品版本更新记录</p>
                </div>
            </div>

            <div class="panel-section">
                <h3>设置</h3>
                <div class="setting-option">
                    <span>语音回复</span>
                    <label class="switch">
                        <input type="checkbox">
                        <span class="slider"></span>
                    </label>
                </div>
                <div class="setting-option">
                    <span>上下文记忆</span>
                    <label class="switch">
                        <input type="checkbox" checked>
                        <span class="slider"></span>
                    </label>
                </div>
                <div class="setting-option">
                    <span>自动翻译</span>
                    <label class="switch">
                        <input type="checkbox">
                        <span class="slider"></span>
                    </label>
                </div>
            </div>

            <div class="panel-section">
                <h3>系统状态</h3>
                <div class="knowledge-item">
                    <strong>LangChain版本</strong>
                    <p>v0.0.276</p>
                </div>
                <div class="knowledge-item">
                    <strong>响应时间</strong>
                    <p>平均 0.8 秒</p>
                </div>
                <div class="knowledge-item">
                    <strong>今日服务</strong>
                    <p>已处理 1,243 个请求</p>
                </div>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const chatMessages = document.getElementById('chatMessages');
            const userInput = document.getElementById('userInput');
            const sendButton = document.getElementById('sendButton');

            // 添加示例对话
            function addExampleConversation() {
                const examples = [
                    {sender: 'user', text: '如何集成LangChain到我的项目中？'},
                    {sender: 'bot', text: '集成LangChain通常需要安装langchain包，然后根据您的用例选择适当的模块。您需要帮助的具体是哪方面的集成？'},
                    {sender: 'user', text: '我想实现一个文档问答功能。'},
                    {sender: 'bot', text: '文档问答可以使用LangChain的Document Loaders和Vector Stores。您是否有特定格式的文档需要处理？'}
                ];

                examples.forEach((msg, index) => {
                    setTimeout(() => {
                        addMessage(msg.text, msg.sender);
                    }, (index + 1) * 600);
                });
            }

            // 添加消息到聊天窗口
            function addMessage(text, sender) {
                const messageDiv = document.createElement('div');
                messageDiv.classList.add('message');
                messageDiv.classList.add(sender === 'user' ? 'user-message' : 'bot-message');
                messageDiv.textContent = text;
                chatMessages.appendChild(messageDiv);
                chatMessages.scrollTop = chatMessages.scrollHeight;
            }

            // 发送消息
            function sendMessage() {
                const message = userInput.value.trim();
                if (message) {
                    addMessage(message, 'user');
                    userInput.value = '';

                    // 规则回复：根据关键词/正则给出对应答案
                    setTimeout(() => {
                        const response = generateBotResponse(message);
                        addMessage(response, 'bot');
                    }, 300);
                }
            }

            // 根据问题内容生成机器人回复
            function generateBotResponse(raw) {
                const text = raw.toLowerCase();

                const rules = [
                    { test: /(价格|多少钱|定价|收费|费用)/, answer: '我们提供基础版¥99/月、专业版¥199/月，企业版可按需定制报价。可随时升级或降级。' },
                    { test: /(试用|体验|免费)/, answer: '我们提供7天免费试用，功能完整。使用手机号或邮箱注册即可开通。' },
                    { test: /(退款|退费|发票|开票)/, answer: '支持按月付随时取消，下月不再扣费；需要发票可在账户中心申请电子专票。' },
                    { test: /(客服|支持|帮助|售后|联系)/, answer: '我们提供7×24小时支持：工单、在线聊天与 support@example.com 邮箱，企业用户可享专属群。' },
                    { test: /(部署|安装|对接|集成|api|接口)/, answer: '可通过REST API或SDK集成，提供Java/.NET/Python示例与Webhook。需要的话我可以给出对接步骤。' },
                    { test: /(langchain|向量|文档问答|知识库)/, answer: '文档问答可用文档加载器 + 向量库（如FAISS）构建，检索后将上下文交给模型生成答案。' },
                    { test: /(重置.*密码|忘记.*密码|登录)/, answer: '在登录页通过“忘记密码”重置；若企业SSO请联系管理员在IdP侧重置。' },
                    { test: /(稳定性|可用性|sla|延迟|性能)/, answer: '核心服务SLA 99.9%，平均响应<1s，支持水平扩展与重试熔断。' },
                    { test: /(数据|隐私|安全|合规|加密)/, answer: '数据传输TLS1.2+，静态加密AES-256；支持数据脱敏与访问控制，合规符合GDPR。' },
                    { test: /(你好|你好啊|你好呀)/, answer: '你好，我是智能客服助手，很高兴为您服务。请问有什么可以帮您的吗？' },
                    { test: /(再见|拜拜|再见啊|拜拜啊|再见呀|拜拜呀)/, answer: '再见，感谢您的咨询。希望下次还有机会为您服务。' },
                    { test: /(王燕冰)/, answer: '据我了解，王燕冰是个很美丽很优秀的女孩子。' },
                    { test: /(靳坤瑜)/, answer: '据我了解，靳坤瑜是个很美丽很优秀的女孩子。' },
                    { test: /(高琪雅)/, answer: '据我了解，高琪雅是个很美丽很优秀的女孩子。' },
                    { test: /(八维)/, answer: '据我了解，这个好像是个培训机构吧，不怎么样。' },
                    { test: /(杨佳杰)/, answer: '据我了解，杨佳杰即将是世界首富。' },
                    { test: /(冯康)/, answer: '据我了解，冯康是段怡菲的小狗。' },
                    { test: /(冯康)/, answer: '据我了解，冯康好像说要给段怡菲买好吃的。' },
                ];

                for (const rule of rules) {
                    if (rule.test.test(text)) return rule.answer;
                }

                return '已收到您的问题。我可以提供价格、集成、试用、发票、支持、LangChain等方面的详细解答。请稍微具体一点描述，我会给出更准确的回答。';
            }

            // 事件监听
            sendButton.addEventListener('click', sendMessage);
            userInput.addEventListener('keypress', function(e) {
                if (e.key === 'Enter') {
                    sendMessage();
                }
            });

            // 导航项点击事件
            document.querySelectorAll('.nav-item').forEach(item => {
                item.addEventListener('click', function() {
                    document.querySelectorAll('.nav-item').forEach(i => i.classList.remove('active'));
                    this.classList.add('active');
                });
            });
        });
    </script>
</body>
</html>